
#include "BatCtrl.h"
#include "../debug_new.h"


CBatCtrl::CBatCtrl()
{
	Init();
	m_nIconNum  = 8;
	m_nIndex    = 0;
	//g_pwstate     = POW_UNKNOW;
}

CBatCtrl::CBatCtrl(UINT nID):CBmpBtn(nID)
{
	Init();
	m_nIconNum  = 8;
	m_nIndex    = 0;
	//g_pwstate     = POW_UNKNOW;
}

CBatCtrl::CBatCtrl(wstring strCaption,UINT nID)
:	CBmpBtn(strCaption,nID)
{
	Init();
	m_nIconNum  = 8;
	m_nIndex    = 0;
	//g_pwstate     = POW_UNKNOW;
}

CBatCtrl::CBatCtrl(DWORD dwStyle, wstring strCaption,const CRect &rc, UINT nID)
:	CBmpBtn(dwStyle, strCaption,rc, nID)
{
	Init();
	m_nIconNum  = 8;
	m_nIndex    = 0;
	//g_pwstate     = POW_UNKNOW;
}

CBatCtrl::CBatCtrl(DWORD dwStyle, wstring strCaption, int x, int y, int cx, int cy, UINT nID)
:	CBmpBtn(dwStyle, strCaption, x, y, cx, cy, nID)
{
	Init();
	m_nIconNum  = 8;
	m_nIndex    = 0;
	//g_pwstate     = POW_UNKNOW;
}

CBatCtrl::~CBatCtrl()
{

}

PowerStatusType CBatCtrl::g_pwstate = POW_CHARGEFULL;

void CBatCtrl::SetPWState(PowerStatusType state)
{
	g_pwstate = state;
}

void CBatCtrl::Paint(CDC* pDC)
{
	if(m_rcControl.IsRectEmpty())
	{
		return ;
	}

	if(!IsVisible())
	{
		return;
	}

	if(POW_UNKNOWN == g_pwstate)
	{
		return;
	}
	if(POW_CHARGING == g_pwstate) //animation icon
	{
		m_nIndex++;
		if(m_nIndex >= m_nIconNum - 1 - 1)
		{
			m_nIndex = 0;
		}
		if(m_pImgLstBtn)
		{
			m_pImgLstBtn->Draw(pDC,m_nIndex,m_rcControl.TopLeft());
		}
	}
	else
	{
		if(m_pImgLstBtn)
		{
			m_pImgLstBtn->Draw(pDC,g_pwstate,m_rcControl.TopLeft());
		}
	}
}